# 导入sympy
from sympy import *
# 初始化打印格式，让矩阵一创建方式输出
init_printing(use_unicode=True)
A = Matrix([[1,2,3],[2,2,1],[3,4,3]])
C = Matrix([[2,5],[3,1],[4,3]])
# 判断A是否满秩
if A.rank()==list(A.shape)[0] or A.rank() == list(A.shape)[1]:
    print("A为满秩矩阵,A的秩为：",A.rank())
    # 计算矩阵X
    print("矩阵X为\n", A.inv() * C)
else:
    print("A为降秩矩阵，A的秩为：",A.rank())
